<?php
class IndexController extends LBController
{
    public function indexAction()
    {
        $this->assign('title', "index");

        $frd = new Friend();
        $frdId = filter_var($this->getParam('u', 0), FILTER_VALIDATE_INT);

        if ($frd->authViewProfile($this->getUserId(), $frdId))
        {
            $this->baseContent();
            $this->render();
        }
        else
        {
            $prf = new Profile();
            $profile = $prf->findByUserId($frdId);

            if (null == $profile)
            {
                throw new UserException(UserException::USER_NOT_EXIST);
            }

            $this->assign('skipSiderBar', true);
            $this->assign('profile', $profile->toArray());
            $this->render('profilecard');
        }
    }

    public function demoAction()
    {
        $this->render();
    }
}
